package com.bcqn.enums;

public enum ConfigReturnType {
    /**
     * 小程序
     */
    MINI_PROGRAM(0, "小程序"),
    /**
     * H5
     */
    HTML5(1, "H5"),
    /**
     * 其他小程序
     */
    OTHER_MINI_PROGRAM(2, "其他小程序");

    private final Integer value;
    private final String title;

    ConfigReturnType(Integer value, String title) {
        this.value = value;
        this.title = title;
    }

    public Integer value() {
        return value;
    }

    public Integer getValue() {
        return value;
    }

    public String getTitle() {
        return title;
    }

    public String getTitle(Integer value) {
        return of(value).title;
    }

    public static ConfigReturnType of(final Integer value) {
        for (ConfigReturnType e : ConfigReturnType.values()) {
            if (e.value != null && e.value.equals(value)) {
                return e;
            }
        }
        return null;
    }

    public static ConfigReturnType nameOf(final String title) {
        for (ConfigReturnType e : ConfigReturnType.values()) {
            if (e.title.equals(title.trim())) {
                return e;
            }
        }
        return null;
    }


    @Override
    public String toString() {
        return this.title;
    }
}
